﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLQTPM_ThuDuc_Group7.DAO;
using QLQTPM_ThuDuc_Group7.DTO;
using System.Data;

namespace QLQTPM_ThuDuc_Group7.BUS
{
    class DiaDiemBUS
    {
        public static DataTable LoadDuLieu()
        {
            DataTable tb = new DataTable();
            tb = DiaDiemDAO.LoadDuLieu();
            return tb;
        }
        public static bool Delete(int matendiadiem)
        {
            bool flag = true;
           
            bool kq = DiaDiemDAO.XoaDiaDiem(matendiadiem);
            if (kq == false)
            {
                flag = false;
            }
            else
            {
                bool kq1 = TuKhoaDiaDiemDAO.XoaTuKhoaDiaDiem(matendiadiem);
                if (kq1== false)
                    flag = false;
                else
                {
                    bool kq2 = TenDiaDiemDAO.XoaTenDiaDiem(matendiadiem);
                    if (kq2 == false)
                        flag = false;
                }
            }
            return flag;
        }

        //Lấy Dữ liệu Địa Điểm theo mã tên địa điểm --Delete---
        public static DataTable LayDuLieuDDTheoMaTenDiaDiem(int matendiadiem)
        {
            DataTable dtb = DiaDiemDAO.LayDuLieuDDTheoMaTenDiaDiem(matendiadiem);
            return dtb;
        }
        //------Bat dau Insert-----
        public static int ThemDanhSachDiaDiem(List<DiaDiemDTO> lstDuLieu)
        {
            DiaDiemDAO diaDiemDAO = new DiaDiemDAO();
            return diaDiemDAO.ThemDanhSachDuLieu(lstDuLieu);
        }

        public static DataTable LayDSDiaDiemByTuKhoaDD_DichVu(int madichvu, string tukhoa)
        {
            DiaDiemDAO diadiemDao = new DiaDiemDAO();
            return diadiemDao.LayDSDiaDiemByTuKhoaDD_DichVu(madichvu, tukhoa);
        }
        public static DataTable LayDSDiaDiemByTuKhoaDD_KhuVuc(int maduong, int maphuong, int maquanhuyen, int matinhthanh, string tukhoa)
        {
            DiaDiemDAO diadiemDao = new DiaDiemDAO();
            return diadiemDao.LayDSDiaDiemByTuKhoaDD_KhuVuc(maduong, maphuong, maquanhuyen, matinhthanh, tukhoa);
        }

        public bool ThemDiaDiem(DiaDiemDTO dvDTO)
        {
            DiaDiemDAO diaDiemDAO = new DiaDiemDAO();
            return diaDiemDAO.ThemDiaDiem(dvDTO);
        }

        public bool isNumberic(string str)
        {
            DiaDiemDAO diaDiemDAO = new DiaDiemDAO();
            return diaDiemDAO.isNumberic(str);
        }
        //------Kết thúc Insert-----
        //------Bắt đầu Updata-----
        public static bool CapNhatDiaDiem(DiaDiemDTO dd)
        {
            bool flag = DiaDiemDAO.SuaDiaDiem(dd);
            if (flag == true)
                return true;
            else
                return false;
        }

        public static DiaDiemDTO LoadThongTinDiaDiem(int ma)
        {
            return DiaDiemDAO.LoadThongTinDiaDiem(ma);
        }

        public static DataTable LoadTenDiaDiem()
        {
            return DiaDiemDAO.LoadTenDiaDiem();
        }

        public static DataTable LoadDichVu()
        {
            return DichVuDAO.LoadDichVu();
        }

        public static DataTable LoadDuong()
        {
            return DuongDAO.LoadDuong();
        }

        public static DataTable LoadPhuong()
        {
            return PhuongDAO.LoadPhuong();
        }

        public static DataTable LoadQuanHuyen()
        {
            return QuanHuyenDAO.LoadQuanHuyen();
        }

        public static DataTable LoadTDiaDiem()
        {
            return TenDiaDiemDAO.LoadDiaDiem();
        }

        public static DataTable LoadTinhThanh()
        {
            return TinhThanhDAO.LoadTinhThanh();
        }
    }
}
